<%@ include file="IsProff.jsp"%>
<%@ page import="database.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*" %>
<%
String profId = (String) session.getAttribute("ProfID");

if(profId != null) {
        DBCon db = new DBCon();
	String name;

	String data = "";

	String[] events = new String[2];
	String pid = "";
	
	SimpleDateFormat time = new SimpleDateFormat("hh:mm:ss a");
	SimpleDateFormat day = new SimpleDateFormat("MM/dd/yyyy");
	events[0]= day.format(new Date());
	events[1]= time.format(new Date());
	String type="";
	Enumeration project = request.getParameterNames();

	while(project.hasMoreElements())
	{
		name = (String)project.nextElement();
		if(name.equals("pid"))
			pid = request.getParameter(name);
		else if(name.equals("type"))
                        type = request.getParameter(name);
		else	if(!(name.equals("fColor") || name.equals("fStyle") || name.equals("fSize")))
			{	
				data += name+"= '"+request.getParameter(name)+"',";
			}
	
	}
        
        String status = db.getProjectStatus(pid);
        if(status.equals("uncompleted") && type.equals("pending"))
         {
            data += "status ='pending', last_modification_date ='"+events[0]+" "+events[1]+"',professorid ="+profId+" where id ="+pid;
         }
	else
            data += "last_modification_date ='"+events[0]+" "+events[1]+"',professorid ="+profId+" where id ="+pid;
	
        
           db.updateProject(data);


	out.println("<script>alert('Update done');window.close();</script>");
}
else {
	out.println("<script>alert('you are not authorized to upload file');window.close();</script>");
}

%>